package org.vic.decorator;

/**
 * Created by VIC.Huang on 2016/8/29.
 */
public class Main {
    public static void main(String[] args) {
        Component component = new ConcreteComponent();
        System.out.println("--------------------------------");
        component.method();     // 原来的方法
        System.out.println("---------- 装饰成A ---------");
        ConcreteDecoratorA decoratorA = new ConcreteDecoratorA(component);
        decoratorA.method();
        System.out.println("---------- 装饰成B ---------");
        ConcreteDecoratorB decoratorB = new ConcreteDecoratorB(component);
        decoratorB.methodB();
        decoratorB.method();
        System.out.println("---------- 装饰成A后再装饰成B ---------");
        decoratorB = new ConcreteDecoratorB(decoratorA);
        decoratorB.methodB();
        decoratorB.method();
    }
}
